<!-- 从业端-讲师列表-讲师简历 -->
<template>
	<view class="resume-container">
		<!-- 用户基本信息 -->
		<view class="user-info">
			<view class="info-main">
				<view class="name-line">
					<text class="name">{{base_info.base.bt_name}}</text>
				</view>
				<view class="meta-info">
					<text class="gender">{{base_info.base.bt_zhicheng}}</text>
					<text>|</text>
					<text>{{ yearServer(base_info.base.bt_workdate) }}</text>
					<text>|</text>
					<text>{{ base_info.base.bt_zyly }}</text>
					<text>|</text>
					<text>{{base_info.base.workindate}}</text>
				</view>
				<view class="contact-info">
					<text class="phone">{{ base_info.base.bt_zyly }}</text>
				</view>
			</view>
			<view class="avatar-container">
				<image :src="base_info.base.bt_header_uri[0].url" class="avatar" mode="aspectFill"></image>
			</view>
		</view>

		<!-- 分隔线 -->
		<u-line color="#c1c3c7" length="90%" margin="0 10px"></u-line>

		<!-- 个人介绍 -->
		<view class="section">
			<view class="section-header">
				<text class="title">个人介绍</text>
			</view>
			<view class="section-content">
				<!-- 加载更多 -->
				<u-read-more :show-height="200" :toggle="true" :shadow-style="shadowStyle" color="#03B8CD">
					<rich-text :nodes="base_info.base.bt_desc"></rich-text>
				</u-read-more>
			</view>
		</view>

		<!-- 分隔线 -->
		<u-line color="#c1c3c7" length="90%" margin="0 10px"></u-line>

		<!-- 职业证书 -->
		<view class="section">
			<view class="section-header">
				<text class="title">相关课程</text>
			</view>
			<view class="certificates" v-for="(item,index) in base_info.zyzs" :key="index">
				<view class="cert-names">
					<text class="cert-name">{{item.jlzs_name}}({{item.jlzs_level}})</text>
				</view>
			</view>
		</view>

		<!-- 分隔线 -->
		<u-line color="#c1c3c7" length="90%" margin="0 10px"></u-line>

		<!-- 空块 -->
		<view class="section">
			<view class="section-header">
				<text class="title"></text>
			</view>
			<view class="section-content">
				<view class="workSection">
				</view>
				<view class="timeSection">
				</view>
			</view>
		</view>	
	</view>
</template>

<script>
	import util from '@/utils/util.js'
	export default {
		data() {
			return {
				loading: false,
				expanded: false, // 控制个人介绍是否展开
				btCode: '', ///传递过来的讲师简历的tdusercode
				// 简历内容
				base_info: {
					base: {
						name: '',
						sex: '',
						birth: '',
						xueli: '',
						workindate: '',
						phoneno: '',
						wxopenid: '',
						header_img: ''
					},
					qz: {

					},
					// 个人介绍
					personal: {
						jlbi_personview: ''
					},
					zyzs: [],
					gzjl: [],
					hyry: [],
					jyjl: [],
					pxjl: []
				},
			}
		},
		onLoad(options) {
			this.btCode = options.btcode
			console.log('收消息：',this.btCode)
		},
		onShow() {
			this.$u.api.querybt({
				btcode: this.btCode
			}).then(res => {				
				let baseInfo = res.data.base_info
				// // 赋值讲师信息
				this.base_info.base = baseInfo;
				console.log('讲师简历：', this.base_info.base)
			})
		},
		methods: {
			// 计算工作年限
			yearServer(workTime) {
				let diff = util.calculateDateDifference(workTime)
				let workYear = ''
				if (diff.years == 0){
					workYear = diff.months+'个月';
				} else 	if(diff.months == 0){
					workYear = diff.years+'年';
				} else {
					workYear = diff.years+'年'+diff.months+'个月';
				}	
				return workYear							
			},
		}
	}
</script>

<style lang="scss" scoped>
	.resume-container {
		// padding: 30rpx;
		background-color: #F1F7F7;
		// min-height: 160vh;

		.user-info {
			display: flex;
			background-color: #F1F7F7;
			border-radius: 16rpx;
			padding: 30rpx;
			// margin-bottom: 5rpx;

			.avatar-container {
				margin-right: 30rpx;

				.avatar {
					width: 120rpx;
					height: 160rpx;
					background: #E9F3FD;
					border-radius: 8rpx 8rpx 8rpx 8rpx;
				}
			}

			.info-main {
				flex: 1;

				.name-line {
					display: flex;
					align-items: center;
					// margin-bottom: 30rpx;

					.name {
						font-size: 36rpx;
						font-weight: bold;
						color: #333;
						margin-right: 20rpx;
					}

					.gender {
						font-size: 24rpx;
						color: #2979ff;
						background-color: #F1F7F7;
						padding: 4rpx 15rpx;
						border-radius: 20rpx;
					}
				}

				.meta-info {
					display: flex;
					align-items: center;
					font-size: 26rpx;
					color: #666;
					// margin-bottom: 30rpx;

					text {
						margin-right: 15rpx;

						&:last-child {
							margin-right: 0;
						}
					}
				}

				.contact-info {
					.phone {
						// display: block;
						font-size: 26rpx;
						color: #666;
						// margin-bottom: 8rpx;
						margin-right: 10px;

						&:last-child {

							margin-bottom: 0;
						}
					}
				}
			}
		}

		.section {
			background-color: #F1F7F7;
			border-radius: 16rpx;
			padding: 30rpx;

			.section-header {
				display: flex;
				justify-content: space-between;
				align-items: center;
				padding-bottom: 20rpx;
				// border-bottom: 1rpx solid #f0f0f0;			


				.title {
					font-size: 32rpx;
					font-weight: bold;
					color: #333;
				}

				.status {
					font-size: 26rpx;
					color: #03B8CD;
				}
			}

			.section-content {
				.intention-item {
					display: flex;
					font-size: 28rpx;
					color: #666;
					margin-bottom: 15rpx;

					.label {
						color: #333;
						font-weight: bold;
						margin-right: 10rpx;
					}
				}
			}

			// 个人证书样式
			.certificates {
				.cert-row {
					margin-bottom: 20rpx;
				}

				.cert-names {
					// flex 通过 flex-direction 改变排列样式
					display: flex;
					flex-direction: column;

					.cert-name {
						width: 48%;
						font-size: 26rpx;
						color: #666;
						text-align: center;
					}
				}
			}
		}

		// 岗位与时间
		.timeSection {
			margin: 10px 0;

			.title-name {
				margin-right: 20px;
			}
		}
	}
</style>